#coding=utf-8
#xiapibuy
#yuc
#https://pypi.tuna.tsinghua.edu.cn/simple
#https://xiapi.xiapibuy.com/%E6%89%8B%E6%A9%9F%E5%B9%B3%E6%9D%BF%E8%88%87%E5%91%A8%E9%82%8A-cat.70
import os,requests,json,sys,re,time
import random
from lxml.html import fromstring, tostring
from lxml import etree
import copy
try:
    from .spider.spider import get,post
    from .spider.aiospider import *
    from .config import HTTP_HEADER,ROOT_PATH
    from .config import str_url_category,str_url_cat_shop_list,str_url_run_follow,str_url_run_unfollow,\
                        str_url_shop_follower_list,str_url_username_id,str_url_shop_following_list
    from .log import Logger
except:
    from spider.spider import get,post
    from spider.aiospider import *
    from config import HTTP_HEADER,ROOT_PATH
    from config import str_url_category,str_url_cat_shop_list,str_url_run_follow,str_url_run_unfollow,\
                        str_url_shop_follower_list,str_url_username_id,str_url_shop_following_list
    from log import Logger
import traceback,codecs
import chardet

logger = Logger(log_file_name=os.path.splitext(__file__)[0]+".log",logger_name=__file__, colorful=False).getlog()

DEBUG = False


def ranstr(num):
   
    H = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
    salt = ''
    for i in range(num):
        salt += random.choice(H)
    return salt

class Xiapibuy():
    def __init__(self):
        pass
        if DEBUG:
            print("***********运行在debug模式**************")
        self.cookie = ''
        self.csrftoken = ''

    def xiapi_set_cookie(self,str_cookie):
        #res = requests.get('https://xiapi.xiapibuy.com/api/v1/account_info',headers=HTTP_HEADER)
        #rcookie = requests.utils.dict_from_cookiejar(res.cookies)
        rcookie = {}
        rcookie['SPC_EC'] = str_cookie
        rcookie['csrftoken'] = ranstr(32) #'pLliigV38TwNPzSHDth7rxOPjSfd5Edc'

        # rcookie['SPC_IA'] = '1'
        # rcookie['SPC_U'] = '152288110'
        # rcookie['welcomePkgShown'] = 'true'
        # rcookie['_med'] = 'refer'
        # rcookie['SPC_F'] = 'FuS1mXA4G5UhS9LKD9JjVCJK794lsMg6'
        # rcookie['REC_T_ID'] = '32b05f5e-cbf2-11ea-a298-f8f21e2c1869'
        # rcookie['SPC_SI'] = 'kpem1o3626wwf2m3cu6bae0ms72sjggw'
        # rcookie['_gcl_au'] = '1.1.1309096428.1595405166'
        # rcookie['__BWfp'] = 'c1595405171777xf7bca76d8'
        # rcookie['SPC_R_T_ID']='"kAziIuia0pg7CGzpkZ0eD44WbZdqvl7eKKK7jkMToNTT4CxTSd86bTthozL9NM1FvmQWyqWlz5io0zom6cCAOUa2XkPbPg8aXCH1nKnKkV4="'
        # rcookie['SPC_T_IV']='"ovULfTK1HDA0wyrk8mxOZA=="'
        # rcookie['SPC_R_T_IV']='"ovULfTK1HDA0wyrk8mxOZA=="'
        # rcookie['SPC_T_ID']='"kAziIuia0pg7CGzpkZ0eD44WbZdqvl7eKKK7jkMToNTT4CxTSd86bTthozL9NM1FvmQWyqWlz5io0zom6cCAOUa2XkPbPg8aXCH1nKnKkV4="'
        # rcookie['cto_bundle']='pMxRjV9ab2cxNW8wU1JRMCUyRk1IendaRWJqWG9DSWdmNWpOOUsxaUhFeldScU1qWXklMkI4N3RnSXI2NU52QjFmZFRsV2QzWWIwTUlEc1F4JTJGOGo3cERVWmNEMzVmbEdUNmNuV1ZoZlpqQngwM0MlMkZmNFpkRzY5WnJJdGclMkZyUCUyQnBrNUYzTVhJY2hBS3MxTEhtTHVOc2Fpc2QlMkJWMjh0WW1kVGZ2TEYlMkZjR3liRTRTMjlHV1hBJTNE'
        
        str_tmp_rcookie = ''
        # tmp_c = 'SPC_EC=AJUOyRStwP7jxG7VbnppT9q3RoK1KEtuqsZl3zF5G6Hqc6GyCf8Y7EUSHCCowDXVEI7mLIO/BK33QYN0qBZ0SfPq1Foy52iD/D6SBfPx144NDdIvb2m6dsx37Ct3EbYXV7AU2YahlZO6d5ojT9BgDXocNem9kn9cep2PzEelbj0=; _gcl_au=1.1.1309096428.1595405166; csrftoken=pLliigV38TwNPzSHDth7rxOPjSfd5Edc; SPC_U=152288110; welcomePkgShown=true; SPC_F=FuS1mXA4G5UhS9LKD9JjVCJK794lsMg6; REC_T_ID=32b05f5e-cbf2-11ea-a298-f8f21e2c1869; SPC_SI=kpem1o3626wwf2m3cu6bae0ms72sjggw; SPC_EC=AJUOyRStwP7jxG7VbnppT9q3RoK1KEtuqsZl3zF5G6Hqc6GyCf8Y7EUSHCCowDXVEI7mLIO/BK33QYN0qBZ0SfPq1Foy52iD/D6SBfPx144NDdIvb2m6dsx37Ct3EbYXV7AU2YahlZO6d5ojT9BgDXocNem9kn9cep2PzEelbj0=; __BWfp=c1595405171777xf7bca76d8; _med=refer; SPC_IA=1; cto_bundle=pMxRjV9ab2cxNW8wU1JRMCUyRk1IendaRWJqWG9DSWdmNWpOOUsxaUhFeldScU1qWXklMkI4N3RnSXI2NU52QjFmZFRsV2QzWWIwTUlEc1F4JTJGOGo3cERVWmNEMzVmbEdUNmNuV1ZoZlpqQngwM0MlMkZmNFpkRzY5WnJJdGclMkZyUCUyQnBrNUYzTVhJY2hBS3MxTEhtTHVOc2Fpc2QlMkJWMjh0WW1kVGZ2TEYlMkZjR3liRTRTMjlHV1hBJTNE; SPC_R_T_ID="kAziIuia0pg7CGzpkZ0eD44WbZdqvl7eKKK7jkMToNTT4CxTSd86bTthozL9NM1FvmQWyqWlz5io0zom6cCAOUa2XkPbPg8aXCH1nKnKkV4="; SPC_T_IV="ovULfTK1HDA0wyrk8mxOZA=="; SPC_R_T_IV="ovULfTK1HDA0wyrk8mxOZA=="; SPC_T_ID="kAziIuia0pg7CGzpkZ0eD44WbZdqvl7eKKK7jkMToNTT4CxTSd86bTthozL9NM1FvmQWyqWlz5io0zom6cCAOUa2XkPbPg8aXCH1nKnKkV4="'
        # tmp_c = 'SPC_EC=AJUOyRStwP7jxG7VbnppT9q3RoK1KEtuqsZl3zF5G6Hqc6GyCf8Y7EUSHCCowDXVEI7mLIO/BK33QYN0qBZ0SfPq1Foy52iD/D6SBfPx144NDdIvb2m6dsx37Ct3EbYXV7AU2YahlZO6d5ojT9BgDXocNem9kn9cep2PzEelbj0=; csrftoken=pLliigV38TwNPzSHDth7rxOPjSfd5Edc;'
        # #rcookie = cookie_dict    
        # cookie_dict = {}
        # for i in tmp_c.split("; "):
        #     a = i[:i.find('=')]
        #     b = i[i.find('=')+1:]
        #     cookie_dict[a] =b
        # for i in cookie_dict:
        #     print(i,cookie_dict[i])
        for n in rcookie:
            str_tmp_rcookie += "{}={}; ".format(n,rcookie[n])
        #print('***',str_tmp_rcookie)
        #exit()
        #str_tmp_rcookie = 'SPC_F=ywCIywBxPQeI45ghCjtWKpmLzsi6h4PE; REC_T_ID=5bbaf378-cbf2-11ea-95dc-f8f21e1ae922; SPC_SI=xwhz4xy3owohvat7k6drrdn3zst1uen9; _gcl_au=1.1.532211684.1595413562; SPC_EC=AJUOyRStwP7jxG7VbnppT9q3RoK1KEtuqsZl3zF5G6Hqc6GyCf8Y7EUSHCCowDXVEI7mLIO/BK33QYN0qBZ0SfPq1Foy52iD/D6SBfPx144NDdIvb2m6dsx37Ct3EbYXV7AU2YahlZO6d5ojT9BgDXocNem9kn9cep2PzEelbj0=; csrftoken=euUH3TNVKlP4f9EzRHYyhiz3AJKqnOKs; SPC_U=152288110; _med=refer; SPC_IA=1; welcomePkgShown=true; __BWfp=c1595413630201xeb9e83349; SPC_R_T_ID="vznoAaPQZuyv13hl9na5YuQ12bkFQ9S52kYXlIlqm/1aLhR2C5aRUpWO51kw8nyKR+XclXVdZIDLNjgXPZHQgJRWEKFIcI++tCf6Ls5aFc8="; SPC_T_IV="bpkk9yaeXhLKWNI6YxgkXA=="; SPC_R_T_IV="bpkk9yaeXhLKWNI6YxgkXA=="; SPC_T_ID="vznoAaPQZuyv13hl9na5YuQ12bkFQ9S52kYXlIlqm/1aLhR2C5aRUpWO51kw8nyKR+XclXVdZIDLNjgXPZHQgJRWEKFIcI++tCf6Ls5aFc8="'
        self.cookie = str_tmp_rcookie
        self.csrftoken = rcookie['csrftoken']
        logger.info(self.cookie)
        return True
    
    def xiapi_get_cookie(self):
        return self.cookie

    #初始化获取分类列表
    def xiapi_category_get_tree(self):
        #str_url_category = 'https://xiapi.xiapibuy.com/api/v2/fe_category/get_tree'
        html_category = get(str_url_category,HTTP_HEADER,'utf-8')
        if html_category == None:
            return {}
        json_data = json.loads(html_category)
        str_version = json_data['version']
        dict_data = json_data['data']
        #todo 等待细化
        for item in dict_data:
            print(item['main']['catid'],item['main']['display_name'])
        return dict_data
    
    #同上，本地读取
    def xiapi_category_get_tree_local(self):
        with open('categoryhtml.log','r') as f:
            json_local =json.loads(f.read())
            print(json_local['version'])
            #print(bb['data'])
            return json_local['data']

    #组装请求url
    def xiapi_url_displayname_build(self,str_display_name,list_catid):
        pass
    
    #根据店铺分类获取店铺id
    #输入：分类id,待获取的店铺数量，50的整数倍，默认50
    #返回：当前分类下的店铺id列表
    #可能要做newest随机数
    def xiapi_search_shop_items_get(self,num_cat_id,num_shop=50):
        #https://xiapi.xiapibuy.com/api/v2/search_items/?by=relevancy&fe_categoryids=2164&limit=50&newest=0&order=desc&page_type=search&version=2  #子类情况
        #https://xiapi.xiapibuy.com/api/v2/search_items/?by=relevancy&fe_categoryids=62&limit=50&newest=0&order=desc&page_type=search&version=2  #newest=0 每50分页
        list_total_shopid = []
        for num_count in range(int(num_shop/50)):
            str_url = str_url_cat_shop_list.format(num_cat_id,num_count*50)
            logger.info(str_url)
            html_search_items = get(str_url,HTTP_HEADER,'utf-8')
            if html_search_items == None:
                return []
            json_data = json.loads(html_search_items)
            list_items = json_data['items']
            list_shopid = list(map(lambda x: x['shopid'], list_items))
            list_total_shopid.extend(list_shopid)
       
        return list(set(list_total_shopid))
    
    #获取店铺粉丝列表
    #可能要做offset随机数
    def xiapi_shop_follow_get(self,shopid,num_follower=20):
        #https://xiapi.xiapibuy.com/shop/5212303/followers/?offset=0&limit=20&offset_of_offset=0&__classic__=1 #offset控制
        list_total_follower_id = []
        for num_offset in range(0,num_follower,20):
            str_url = str_url_shop_follower_list.format(shopid,num_offset)
            logger.info('获取粉丝列表 '+str_url)
            print(HTTP_HEADER)
            html_followers = get(str_url,HTTP_HEADER,'utf-8')
            if html_followers == None:
                return []
            if DEBUG:
                with open('follow.log','w', encoding='utf-8') as f:
                    f.write(html_followers)
            xpath_follower = '//li/@data-follower-shop-id'
            html_root = etree.HTML(html_followers, etree.HTMLParser(encoding='utf-8'))
            list_follower_id = html_root.xpath(xpath_follower)
            logger.info('当前获取粉丝列表数{}'.format(len(list_follower_id)))
            list_total_follower_id.extend(list_follower_id)
     
        logger.info(list_total_follower_id)
        return list(set(list_total_follower_id))

    #获取店铺关注
    #可能要做offset随机数
    def xiapi_shop_following_get(self,shopid,num_follower=20):
        list_total_following_id = []
        for num_offset in range(0,num_follower,20):
            str_url = str_url_shop_following_list.format(shopid,num_offset)
            logger.info('获取关注列表 '+str_url)
            html_following= get(str_url,HTTP_HEADER,'utf-8')
            if html_following == None:
                return []
            if DEBUG:
                with open('following.log','w', encoding='utf-8') as f:
                    f.write(html_following)
            xpath_following = '//li/@data-follower-shop-id'
            html_root = etree.HTML(html_following, etree.HTMLParser(encoding='utf-8'))
            list_following_id = html_root.xpath(xpath_following)
            logger.info('当前获取关注列表数{}'.format(len(list_following_id)))
            list_total_following_id.extend(list_following_id)
     
        logger.info(list_total_following_id)
        return list(set(list_total_following_id))

    #获取用户信息,返回用户名
    def xiapi_account_info(self):
        try:
            post_header = copy.deepcopy(HTTP_HEADER)
            post_header['cookie'] = self.cookie
            res_text = get('https://xiapi.xiapibuy.com/api/v1/account_info',post_header,"utf-8")
            json_data = json.loads(res_text)
            print(json_data['username'])
            return json_data['username']
        except Exception as err:
            logger.error(err)
            return None

    #执行关注
    #需求输入一个cookie信息发过来
    def xiapi_follower_done(self,id_list):
        #https://xiapi.xiapibuy.com/buyer/follow/shop/13004521/
        try:
            list_url = [str_url_run_follow.format(id) for id in id_list]
            logger.info('执行关注 ')
            logger.info(list_url)
            dd = {}
            post_header = copy.deepcopy(HTTP_HEADER)
            post_header['cookie'] = self.cookie
            dd['csrfmiddlewaretoken'] = self.csrftoken  #带一个token 很奇怪
            a=AsnycSpider()
            a.aiopost(list_url,post_header,dd)
            return a.result    
            
        except Exception as err:
            logger.error(err)
            return None

    #取消关注
    def xiapi_unfollower_done(self,id_list):
        #https://xiapi.xiapibuy.com/buyer/unfollow/shop/5839396/
        try:
            
            list_url = [str_url_run_unfollow.format(id) for id in id_list]
            logger.info('执行取消关注 ')
            logger.info(list_url)
            dd = {}
            post_header = copy.deepcopy(HTTP_HEADER)
            post_header['cookie'] = self.cookie
            dd['csrfmiddlewaretoken'] = self.csrftoken  #带一个token 很奇怪
            a=AsnycSpider()
            a.aiopost(list_url,post_header,dd)
            return a.result
            
        except Exception as err:
            logger.error(err)
            return None
    
    #返回当前用户id与当前关注数量
    def xiapi_current_user_id(self,str_username):
        pass
        #https://xiapi.xiapibuy.com/api/v2/shop/get?username=sixonehyu
        str_url = str_url_username_id.format(str_username)
        logger.info('获取{}用户id. '.format(str_username)+str_url)
        html_user_id = get(str_url,HTTP_HEADER,'utf-8')
            
        json_data = json.loads(html_user_id)
        num_shopid = json_data['data']['shopid']
        num_current_following_count = json_data['data']['account']['following_count']
        
        logger.info('获取成功，当前{}用户id为{},共计{}个关注对象.'.format(str_username,num_shopid,num_current_following_count))
        return num_shopid,num_current_following_count

    '''
    根据输入的url进行对此店铺的粉丝进行关注
    默认进行20个关注
    '''
    def xiapi_saleitem_get_follower(self,str_url,num_control=0):
        #@https://xiapi.xiapibuy.com/%E3%80%90A12%E3%80%91%F0%9F%94%A5%E5%8F%B0%E7%81%A3%E7%8F%BE%E8%B2%A8%F0%9F%94%A5%E5%85%A9%E6%AC%BE%E5%A4%9A%E8%89%B2%E6%A3%89%E8%B3%AA%E5%A5%BD%E7%A9%BF%F0%9F%91%8D%F0%9F%8F%BB%E5%8F%AF%E6%8B%86%E8%83%B8%E5%A2%8A%E4%BA%A4%E5%8F%89%E7%BE%8E%E8%83%8CBra%F0%9F%92%95%E5%BD%88%E5%8A%9B%E8%83%8C%E5%BF%83%F0%9F%92%95%E5%B0%8F%E5%8F%AF%E6%84%9B%F0%9F%92%95%E5%85%A7%E8%A1%A3%F0%9F%92%95%E8%83%B8%E7%BD%A9-i.28969561.1298245850
        if self.cookie == '':
            return {'status':-1,'msg':'cookie错误'}
        p = re.compile('-i.(\d+).\d+')
        list_shop_id = p.findall(str_url)
        if len(list_shop_id) != 1:
            return {'status':-4,'msg':'店铺获取失败'}
        num_shop_id = list_shop_id[0]
        list_total_shop_follower = self.xiapi_shop_follow_get(num_shop_id,20)     #默认20个
        #DEBUG取1个就好
        if DEBUG and len(list_total_shop_follower) > 1:
            list_total_shop_follower = list_total_shop_follower[:1]
        else:
            if num_control != 0 and len(list_total_shop_follower) > 1:
                list_total_shop_follower = list_total_shop_follower[:num_control]

        result = self.xiapi_follower_done(list_total_shop_follower)
        print('******',result)
        if result == None or len(result) == 0:
            return {'status':-10,'msg':u'其他问题,共完成0次取消关注'}
        
        num_sucess = 0
        for item in result:
            if item.find('error_not_login') != -1:           #未登陆。或者cookie出问题情况
                return {'status':-6,'msg':u'user_token用户登陆信息出现问题'}
            if item.find('success') != -1:
                num_sucess += 1
        
        return {'status':1,'msg':'店铺共完成{}关注任务'.format(num_sucess),'data':num_sucess}


    #集成调用
    # 获取输入类别（可以是子分类）
    # 指定要关注商铺数量  50整数倍
    # 指定全商铺 想关注粉丝总数量 20整数倍
    # 并执行关注
    def xiapi_main_run_get_follower(self,num_cat_id,num_cat_shop_count=50,num_total_shop_follower=20,num_control = 0):
        if self.cookie == '':
            return {'status':-1,'msg':'cookie错误'}
        list_shopid = self.xiapi_search_shop_items_get(num_cat_id,num_cat_shop_count)
        num_list_shopid = len(list_shopid)
        logger.info('共找到shopid{}个'.format(num_list_shopid))
       
        #执行随机关注
        if num_list_shopid > 10:
            if DEBUG:#只获取2个测试
                list_random_num = random.sample(range(0,num_list_shopid-1),2)
            else:
                list_random_num = random.sample(range(0,num_list_shopid-1),10)
            list_random_shopid = list(map(lambda x: list_shopid[x], list_random_num))
        else:
            list_random_num = random.sample(range(0,num_list_shopid-1),num_list_shopid)
            list_random_shopid = list(map(lambda x: list_shopid[x], list_random_num))
        logger.info('随机关注店铺的id：{}'.format(list_random_shopid))
        num_sigle_shop_follower = int(num_total_shop_follower/len(list_random_shopid)) + 1  #单个店铺需要关注的数量
        #获取要关注人的id列表
        list_total_shop_follower=[]
        for item in list_random_shopid:
            list_total_shop_follower.extend(self.xiapi_shop_follow_get(item,num_sigle_shop_follower))
            if len(list_total_shop_follower) > num_total_shop_follower:  #只获取大于设置数量的待关注id就好
                break
        #对关注人id执行关注
        if DEBUG and len(list_total_shop_follower) > 1:
            list_total_shop_follower = list_total_shop_follower[:1]
        else:
            if num_control != 0 and len(list_total_shop_follower) > 1:
                list_total_shop_follower = list_total_shop_follower[:num_control]

        result = self.xiapi_follower_done(list_total_shop_follower)
        print('******',result)
        if result == None or len(result) == 0:
            return {'status':-10,'msg':u'其他问题,共完成0次取消关注'}

        num_sucess = 0
        for item in result:
            if item.find('error_not_login') != -1:           #未登陆。或者cookie出问题情况
                return {'status':-6,'msg':u'user_token用户登陆信息出现问题'}
            if item.find('success') != -1:
                num_sucess += 1
         
        return {'status':1,'msg':'共完成{}关注任务'.format(num_sucess),'data':num_sucess}

    #执行取消关注
    def xiapi_main_run_get_unfollower(self):
        str_username = self.xiapi_account_info()
        if str_username == None:
            return
        num_user_shopid,num_user_following_count = self.xiapi_current_user_id(str_username)
        if DEBUG:
            num_user_following_count = 20
        if num_user_following_count >50:
            num_user_following_count = 50
        print('num_user_following_count ',num_user_following_count)
        list_following_id = self.xiapi_shop_following_get(num_user_shopid,num_user_following_count)
        if DEBUG and len(list_following_id) > 2:
            list_following_id = list_following_id[:2]
        
        result = self.xiapi_unfollower_done(list_following_id)
        print('******',result)
        if result == None or len(result) == 0:
            return {'status':-10,'msg':u'其他问题,共完成0次取消关注'}
        num_sucess = 0
        for item in result:
            if item.find('error_not_login') != -1:           #未登陆。或者cookie出问题情况
                return {'status':-6,'msg':u'user_token用户登陆信息出现问题'}
            if item.find('success') != -1:
                num_sucess += 1
         
        logger.warning('共执行{}次取消关注.'.format(num_sucess))
        return {'status':1,'msg':'共完成{}次取消关注'.format(num_sucess),'data':num_sucess}



        

def testhtml():
    with open('html.log','r') as f:
        aa = f.read()
        bb =json.loads(aa)
        print(bb['version'])
        #print(bb['data'])
        data_main = bb['data']
        print(len(data_main))
        print(data_main[0])


if __name__ == "__main__":
    
    a = Xiapibuy()
    #url = 'https://xiapi.xiapibuy.com/%E5%A5%B3%E7%94%9F%E8%A1%A3%E8%91%97-cat.62'
    #url = 'https://xiapi.xiapibuy.com/api/v2/search_items/?by=relevancy&fe_categoryids=62&limit=50&newest=0&order=desc&page_type=search&version=2'
    #a.xiapi_search_shop_items_get(62,120)
    #url_follow = 'https://xiapi.xiapibuy.com/shop/5212303/followers/?offset=0&limit=20&offset_of_offset=0&__classic__=1'
    #a.xiapi_shop_follow_get(url_follow)
    #a.xiapi_follower_done(80533979)
    #a.get_html_content()
    #testhtml()
    #a.xiapi_main_run_get_follower(70)
    #a.xiapi_follower_done(38153455)
    #
    #a.xiapi_shop_following_get(152286257,60)
    #a.xiapi_shop_follow_get(152286257,60)
    #a.xiapi_current_user_id('sixonehyu')
    #a.xiapi_category_get_tree()
    cookie = "6+WiKg54sXNLU8hx5soNODzIBr6wx4cc5hmDoNUdEVNNpbOUu2xr7LtcfMFTo0xSulR6QAJE/qkwO9iGVVYeq9gkMi8xvJ4f4Gy7g99w9e45StisNwS4Fjiqd4hhhs1yvePVgw7O+60XnDpq5/c5OQbHGCkTyP3nufZ152n6xhA="
    #cookie = "default"
    a.xiapi_set_cookie(cookie)
    #a.xiapi_account_info()
    a.xiapi_main_run_get_unfollower()
    exit()

    #a.xiapi_unfollower_done([38153455])
    #a.xiapi_follower_done(9977862)
    sss = 'https://xiapi.xiapibuy.com/%E3%80%90A12%E3%80%91%F0%9F%94%A5%E5%8F%B0%E7%81%A3%E7%8F%BE%E8%B2%A8%F0%9F%94%A5%E5%85%A9%E6%AC%BE%E5%A4%9A%E8%89%B2%E6%A3%89%E8%B3%AA%E5%A5%BD%E7%A9%BF%F0%9F%91%8D%F0%9F%8F%BB%E5%8F%AF%E6%8B%86%E8%83%B8%E5%A2%8A%E4%BA%A4%E5%8F%89%E7%BE%8E%E8%83%8CBra%F0%9F%92%95%E5%BD%88%E5%8A%9B%E8%83%8C%E5%BF%83%F0%9F%92%95%E5%B0%8F%E5%8F%AF%E6%84%9B%F0%9F%92%95%E5%85%A7%E8%A1%A3%F0%9F%92%95%E8%83%B8%E7%BD%A9-i.28969561.1298245850'
    a.xiapi_saleitem_get_follower(sss)
    exit()
    unf = ['18818643', '2815922', '41105849', '133009950', '1497414']
    for i in unf:
        if a.xiapi_unfollower_done(i)!= False:
            print('unf')